<template>
  <div>
    <van-nav-bar color="#fff" :border="false">
      <img
        src="~assets/image/arrow_left.png"
        alt=""
        slot="left"
        width="20"
        height="20"
        @click="leftClick"
      />
      <span slot="title">收益</span>
      <span slot="right" @click="rightClick">收益明细</span>
    </van-nav-bar>
    <div class="profit-main">
      <div>
        <p class="money">{{ incomeInfo.yesterdayRebate }}</p>
        <p>昨日收益(元)</p>
      </div>
      <div class="xian"></div>
      <div>
        <p class="money">{{ incomeInfo.todayRebate }}</p>
        <p>今日收益(元)</p>
      </div>
    </div>
    <p class="profit-dang">当前可转出收益(元)</p>
    <p class="moneySum">{{ accountInfo.rebateBalance }}</p>
    <p class="zhuan" @click="next">转出</p>
    <div class="bottom">
      <p class="money btn">{{ incomeInfo.allRebate }}</p>
      <p>共累计收款(元)</p>
    </div>
  </div>
</template>
<script>
import { queryIncomeInfoApi, queryAccountInfoApi } from "network/ApiServe";
export default {
  name: "Profit",
  created() {
    this.userId = localStorage.getItem("userId");
    this.token = localStorage.getItem("token");
  },
  data() {
    return {
      incomeInfo: {},
      accountInfo: {},
    };
  },
  mounted() {
    this.getIncomeInfo();
    this.getAccountInfo();
  },
  methods: {
    leftClick() {
      this.$router.back(-1);
    },
    rightClick() {
      this.$router.push("incomedetails");
    },
    next() {
      this.$router.push("/transferout");
    },
    getIncomeInfo() {
      queryIncomeInfoApi(this.userId)
        .then((res) => {
          if (res.resp_code === "000000") {
            this.incomeInfo = res.result;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    getAccountInfo() {
      queryAccountInfoApi(this.token)
        .then((res) => {
          if (res.resp_code === "000000") {
            this.accountInfo = res.result;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>
<style scoped>
.van-nav-bar {
  background-color: #121212;
}
.van-nav-bar span {
  color: #fff;
}
.xian {
  width: 1px;
  height: 56px;
  background-color: #fff;
}
.profit-main {
  height: 130px;
  background-color: #121212;
  display: flex;
  justify-content: space-around;
  text-align: center;
  align-items: center;
  font-size: 14px;
  color: #fff;
}
.money {
  font-size: 20px;
  margin-bottom: 15px;
}
.profit-dang {
  margin-top: 120px;
  text-align: center;
  color: #000;
  font-size: 16px;
  font-weight: 500;
}
.moneySum {
  margin-top: 10px;
  text-align: center;
  color: #000;
  font-size: 20px;
  font-weight: 500;
}
.zhuan {
  font-weight: 500;
  font-size: 16px;
  color: #000;
  margin: 20px auto;
  background-color: #fff;
  display: flex;
  width: 100px;
  padding: 10px 15px;
  justify-content: center;
  align-items: center;
  border-radius: 23px;
}
.bottom {
  background-color: #fff;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  text-align: center;
  padding-top: 20px;
  font-size: 16px;
  border-radius: 45% 45% 0 0;
  box-shadow: 0px 1px 10px #888;
}
.btn {
  margin-top: 20px;
}
</style>